//
//  AllCategroySectionView.m
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/29.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "AllCategroySectionView.h"



@implementation AllCategroySectionView
{
    CGRect _framee;
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _framee = frame;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setNeedsLayout{
    UILabel *cate = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 100, 20)];
    cate.text = _categroyName;
    cate.font = [UIFont systemFontOfSize:16];
    [self addSubview:cate];
    
    UIButton *allButton = [UIButton buttonWithType:UIButtonTypeCustom];
    allButton.frame = CGRectMake(_framee.size.width - 100, 0, 100, 40);
    [allButton addTarget:self action:@selector(foldType) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:allButton];
    
    _selectType = [[UILabel alloc] initWithFrame:CGRectMake(_framee.size.width - 200, 15, 165, 20)];
    _selectType.textAlignment = NSTextAlignmentRight;
    _selectType.text = _selectString;
    _selectType.font = [UIFont systemFontOfSize:15];
    _selectType.textColor = [UIColor lightGrayColor];
    [self addSubview:_selectType];
    
    _foldImage = [[UIImageView alloc] initWithFrame:CGRectMake(_framee.size.width - 34, 21, 15, 8)];
    _foldImage.image = [UIImage imageNamed:@"GWCicon1_03"];
    if (_isFolding) {
        _foldImage.transform = CGAffineTransformMakeRotation(M_PI);
    }
    [self addSubview:_foldImage];
}

- (void)foldType{
    _fold();
}

@end
